//
//  ThreeImageTableViewCell.m
//  news
//
//  Created by lanou on 15/12/17.
//  Copyright © 2015年 lanou. All rights reserved.
//

#import "ThreeImageTableViewCell.h"
#import "NewsIntroduction.h"

@implementation ThreeImageTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, kWidth - 20, 20)];
        [self addSubview:self.titleLabel fontSize:16.0 color:[UIColor blackColor]];
        
        self.imageView1 = [[UIImageView alloc] initWithFrame:CGRectMake(10, 40, kWidth / 3 - 10, kWidth / 4)];
        [self.contentView addSubview:self.imageView1];
        
        self.imageView2 = [[UIImageView alloc] initWithFrame:CGRectMake(kWidth / 3 + 5, 40, kWidth / 3 - 10, kWidth / 4)];
        [self.contentView addSubview:self.imageView2];
        
        self.imageView3 = [[UIImageView alloc] initWithFrame:CGRectMake(kWidth / 3 * 2, 40, kWidth / 3 - 10, kWidth / 4)];
        [self.contentView addSubview:self.imageView3];
        
        UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(10, kWidth / 4 + 50 - 1, kWidth - 20, 1)];
        lineView.backgroundColor = [UIColor grayColor];
        [self.contentView addSubview:lineView];
    }
    return self;
}

- (void)setNewsIntroduction:(NewsIntroduction *)newsIntroduction
{
    if (_newsIntroduction != newsIntroduction) {
        _newsIntroduction = newsIntroduction;
        self.titleLabel.text = newsIntroduction.title;
        self.imageView1.image = [UIImage imageNamed:@"ic_blank_collect@3x"];
        self.imageView1.image = [UIImage imageNamed:@"ic_blank_collect@3x"];
        self.imageView1.image = [UIImage imageNamed:@"ic_blank_collect@3x"];
        
        [self.imageView1 setImageWithURL:[NSURL URLWithString:newsIntroduction.imgsrc]];
        [self.imageView2 setImageWithURL:[NSURL URLWithString:newsIntroduction.imgsrc2]];
        [self.imageView3 setImageWithURL:[NSURL URLWithString:newsIntroduction.imgsrc3]];
    }
}

- (void)addSubview:(UILabel *)label fontSize:(CGFloat)fontSize color:(UIColor *)color
{
    label.font = [UIFont boldSystemFontOfSize:fontSize];
    label.textColor = color;
    [self.contentView addSubview:label];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
